﻿using System.Threading;

namespace SimpleTerminal.PaintMessage
{
    public class Message
    {
        public enum TEvent
        {
            Initialization,
            StyleChanged,
            Terminal_RowsChanged,
            SizeChanged,
            ScrollContent,
            ScrollBarChanged,
            Paint,
            Render,
            UpdateGraphics,
        }



        public readonly ManualResetEvent _wait = new ManualResetEvent(false);

        public TEvent What = 0;
        public int arg1 = 0;
        public int arg2 = 0;
        public int arg3 = 0;
        public int arg4 = 0;
        public Message()
        {

        }
        public void Release()
        {
            What = 0;
            arg1 = 0;
            arg2 = 0;
            arg3 = 0;
            arg4 = 0;
            _wait.Set();
        }
        public void Reset()
        {
            this._wait.Reset();
        }

        public Message(TEvent what)
        {
            this.What = what;
            this._wait.Reset();
        }
        public Message(TEvent what, int arg1, int arg2, int arg3, int arg4)
        {
            this.What = what;
            this.arg1 = arg1;
            this.arg2 = arg2;
            this.arg3 = arg3;
            this.arg4 = arg4;
        }

        public void Wait()
        {
            _wait.WaitOne();
        }
    }
}
